package com.broada.apm.indicator.api.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.broada.apm.dao.AnalyzerDao;
import com.broada.apm.dao.FilterDao;
import com.broada.apm.dao.L7ModuleDao;
import com.broada.apm.indicator.api.AnalyzerService;
import com.broada.apm.model.Analyzer;
import com.broada.apm.model.PagingList;
import com.broada.apm.model.RemoteProtocolInfo;

public class AnalyzerServiceImpl implements AnalyzerService{

	@Autowired
	AnalyzerDao analyzerDao;
	@Autowired
	FilterDao filterDao;
	@Autowired
	L7ModuleDao l7moduleDao;
	
	@Override
	public PagingList<Analyzer> getAllAnalyzer(int pageIndex, int pageSize) throws Exception{
		return analyzerDao.getAllAnalyzer(pageIndex, pageSize);
	}

	@Override
	public void addAnalyzer(Analyzer analyzer) throws Exception {
		analyzerDao.addAnalyzer(analyzer);
	}

	@Override
	public void deleteAnalyzer(String id) throws Exception {
		// 删除协议分析器信息
		analyzerDao.deleteAnalyzer(id);
		// 删除过滤配置
		filterDao.truncateFilter(id);
	}

	@Override
	public Analyzer getAnalyzerById(String analyzerId) {
		return analyzerDao.getAnalyzerById(analyzerId);
	}
	
	@Override
	public Analyzer queryAnalyzerByIpAndPort(Analyzer analyzer) throws Exception {
		return analyzerDao.queryAnalyzerByIpAndPort(analyzer);
	}

	@Override
	public List<Analyzer> getAllAnalyzerNoPage() throws Exception {
		return analyzerDao.getAllAnalyzerNoPage();
	}

	@Override
	public List<RemoteProtocolInfo> getAnalyzerLog(String analyzerId) throws Exception {
		return l7moduleDao.getAnalyzerLog(analyzerId);
	}
}
